package com.lanou3g.code0418.control;

import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * Created by dllo on 18/4/18.
 */
public class Test01 {
    public static void main(String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {

                for (int i = 0; i < 1000; i++) {

                    System.out.println("a");
                    //线程自己想要放弃掉CPU资源，但是具体是否CPU放弃会放弃它，CPU说的算
                    Thread.yield(); //一种意愿（资源紧张的时候，可以起到微调的作用）
                }
            }
        }).start();


        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {

                    System.out.println("b");
                    Thread.yield();
                }
            }
        }).start();



    }
}
